﻿@model PagedList.IPagedList<SIFIET.Models.Post> 
           

@{
    ViewBag.Title = "Filtro de Noticias";
}

<h1>Filtro de Noticias </h1> 
@if (Model.Count() != 0)
{
<table>
    <tr>
        <th width = "150"  >
            Usuario
        </th>
        <th width = "150" >
            Título
        </th>
        <th >
            Resumen
        </th>
        <th width = "185">
            Fecha de Publicación
        </th>
        <th width = "185">
            Fecha de Actualizacion
        </th>
        <th width = "100">
            Autorizado
        </th>    
        <th width = "100">
            Estado
        </th>     
         
        @if (ViewBag.CurrentFilter == "Mas Likes")
             {
                 <th width = "165">
                 Numero de Likes 
                 </th> 
             }
        @if (ViewBag.CurrentFilter == "Mas Votada")
            {
                <th width = "165">
                Votos Promedio
                </th>  
            } 
        <th width = "100">
            Acciones
        </th>      
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.User.FirstNames)
                @Html.DisplayFor(modelItem => item.User.LastNames)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td style="text-align: justify;">
                @Html.DisplayFor(modelItem => item.Abstract)
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.PublicationDate)
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.UpdateDate)
            </td>
            <td class="center">                
                @if (item.Autorized == 0)
                {
                    @Html.Label("NO");
                }
                else
                {
                    @Html.Label("SI");
                }
            </td>
            <td class="center">
                @if (item.Estate == 0)
                {
                    @Html.CheckBox("Estado", false, htmlAttributes: new { @id = "CBE" + item.Id, @onclick = "CambiarEstadoPost('" + item.Id + "')" });
                }
                else
                {
                    @Html.CheckBox("Estado", true, htmlAttributes: new { @id = "CBE" + item.Id, @onclick = "CambiarEstadoPost('" + item.Id + "')" });
                }
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.Main)
            </td>
            <td class="center">
                @Html.ActionLink(" ", "Edit", new { id = item.Id }, htmlAttributes: new { @class = "btnedit", @title = "Editar" }) 
                @Html.ActionLink(" ", "Details", new { id = item.Id }, htmlAttributes: new { @class = "btndetails", @title = "Detalles" })
            </td>
            
        </tr>
    }
</table>

<div>
    Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    de @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "UserFilter", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Anterior", "UserFilter", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:<<
        @Html.Raw("   ");
        @:< Anterior
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Siguiente>", "UserFilter", new { page = Model.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "UserFilter", new { page = Model.PageCount })
    }
    else
    {
        @:Siguiente >
        @Html.Raw(" ")
        @:>>
    }
</div>

<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" 
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/menu.js")" type="text/javascript"></script>

}

@if (Model.Count() == 0)
{
    <p>No hay coincidencias</p>
}
<br/>


<p>    
    @Html.ActionLink("Regresar al Listado", "UserIndex", null, htmlAttributes: new { @class = "ebutton blue" })
</p>